package change;

import fix.FixLink;
import objects.CarNodeStore;
import objects.LinkNode;

/**
 * @author web
 * 能力/信息素消散变化。
 */
public class ChangePheromone {
    public static void update(CarNodeStore carNodeStore) {
        double change = 0.8;
        // TODO:这里需要编写信息素消散过程，即在建立链路后，对车辆的每次移动后都要在这里把链路的信息素都消散。
        LinkNode head = carNodeStore.getHead();
        LinkNode cur = head;
        double abilityCur;
        while (cur != null) {
            abilityCur = cur.getAbility();
            if ((change * abilityCur) < (abilityCur * 0.1)) {
                FixLink.fix(cur, carNodeStore);
            } else {
                abilityCur = change * abilityCur;
                cur.setAbility(abilityCur);
            }
            cur = cur.getNext();
        }
    }
}
